package com.ruoyi.web.controller.golang;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActivityProcess;
import com.ruoyi.system.service.IActivityProcessService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动流程Controller
 * 
 * @author ruoyi
 * @date 2025-01-12
 */
@Controller
@RequestMapping("/system/process")
public class ActivityProcessController extends BaseController
{
    private String prefix = "system/process";

    @Autowired
    private IActivityProcessService activityProcessService;

    @RequiresPermissions("system:process:view")
    @GetMapping()
    public String process()
    {
        return prefix + "/process";
    }

    /**
     * 查询活动流程列表
     */
    @RequiresPermissions("system:process:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActivityProcess activityProcess)
    {
        startPage();
        List<ActivityProcess> list = activityProcessService.selectActivityProcessList(activityProcess);
        return getDataTable(list);
    }

    /**
     * 导出活动流程列表
     */
    @RequiresPermissions("system:process:export")
    @Log(title = "活动流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActivityProcess activityProcess)
    {
        List<ActivityProcess> list = activityProcessService.selectActivityProcessList(activityProcess);
        ExcelUtil<ActivityProcess> util = new ExcelUtil<ActivityProcess>(ActivityProcess.class);
        return util.exportExcel(list, "活动流程数据");
    }

    /**
     * 新增活动流程
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动流程
     */
    @RequiresPermissions("system:process:add")
    @Log(title = "活动流程", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActivityProcess activityProcess)
    {
        return toAjax(activityProcessService.insertActivityProcess(activityProcess));
    }

    /**
     * 修改活动流程
     */
    @RequiresPermissions("system:process:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ActivityProcess activityProcess = activityProcessService.selectActivityProcessById(id);
        mmap.put("activityProcess", activityProcess);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动流程
     */
    @RequiresPermissions("system:process:edit")
    @Log(title = "活动流程", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActivityProcess activityProcess)
    {
        return toAjax(activityProcessService.updateActivityProcess(activityProcess));
    }

    /**
     * 删除活动流程
     */
    @RequiresPermissions("system:process:remove")
    @Log(title = "活动流程", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(activityProcessService.deleteActivityProcessByIds(ids));
    }
}
